﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<int>" %>
<%@ Import Namespace="CRM.Resourses" %>

<%
    var coursesCol = new CRM.Database.Model.TrainingsCoursesCollection();
    var rubricsCol = new CRM.Database.Model.RubricsCollection();
%>

<%Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdTrainingsCourseses";
                                        settings.KeyFieldName = "IdTrainingsCourse";
                                        settings.CallbackRouteValues = new { Controller = "TC", Action = "TrainingsRemoteCoursesRequestPartial", customerId = Model};
                                        settings.SettingsPager.PageSize = 20;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = " ";
                                            column.FieldName = "IdTrainingsCourse";
                                            column.ColumnType = MVCxGridViewColumnType.HyperLink;
                                            column.Settings.AutoFilterCondition = AutoFilterCondition.Contains;
                                            HyperLinkProperties properties = column.PropertiesEdit as HyperLinkProperties;
                                            String urlFormatString = Url.Action("TrainingsRemoteRequestCreate", "TC", new RouteValueDictionary(new { courseId = "{0}", customerId = Model }));
                                            properties.NavigateUrlFormatString = HttpUtility.UrlDecode(urlFormatString);
                                            properties.TextField = "LinkText";
                                        });
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsCourseName;
                                            column.FieldName = "Name";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "IdRubric";
                                            column.Caption = Resourses.TrainingsRubric;
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                comboBoxProperties.DataSource = rubricsCol.RubricsActiveList;
                                                //comboBoxProperties.DataSource = DB.GetLocalizedRubricsNames(Thread.CurrentThread.CurrentCulture.ToString());
                                                comboBoxProperties.TextField = "LocalizedName";
                                                comboBoxProperties.ValueField = "IdRubric";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsDuration;
                                            column.FieldName = "Duration";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsParticipantCount;
                                            column.FieldName = "ParticipantCount";
                                            
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsTrainersList;
                                            column.FieldName = "TrainersColumn";
                                            column.ColumnType = MVCxGridViewColumnType.Memo;
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsAudtoriumsList;
                                            column.FieldName = "AuditoriumsColumn";
                                            column.ColumnType = MVCxGridViewColumnType.Memo;
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.TrainingsPlaces;
                                            column.FieldName = "PlacesColumn";
                                            column.ColumnType = MVCxGridViewColumnType.Memo;
                                        });

                                        //settings.Columns.Add(column =>
                                        //{
                                        //    column.FieldName = "IdTrainingCoursesType";
                                        //    column.Caption = Resourses.TrainingCoursesType;
                                        //    column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                        //    var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                        //    if (comboBoxProperties != null)
                                        //    {
                                        //        comboBoxProperties.DataSource = DB.GetLocalizedTrainingCoursesTypesNames(Thread.CurrentThread.CurrentCulture.ToString());
                                        //        comboBoxProperties.TextField = "LocaLizedString";
                                        //        comboBoxProperties.ValueField = "Id";
                                        //        comboBoxProperties.ValueType = typeof(int);
                                        //    }
                                        //});

                                    }).Bind(coursesCol.FullDefinedRemoteCourses).GetHtml();
                                    //}).Bind(DB.GetFullDefinedRemoteCourses()).GetHtml();
%>